<?php


class TbfFile {
    //列出目录下面的文件路径数组,已去掉'.'和'..',路径已和目录拼接,路径可以直接访问文件
    static function dirListFile($dirPath){
        $list = array();
        if (!is_dir($dirPath)) {
            throw new Exception('[dirListFile] not a directory dirPath:['.$dirPath.']');
        }
        $dh = opendir($dirPath);
        if (empty($dh)){
            throw new Exception('[dirListFile] opendir fail dirPath:['.$dirPath.']');
        }
        $i=0;
        while (($file = readdir($dh)) !== false) {
            if ($file==='.'|| $file==='..'){
                continue;
            }
            $list[] = $dirPath.'/'.$file;
        }
        closedir($dh);
        return $list;
    }
    //返回文件的扩展名,并转为小写
    static function getExtLower($path){
        $ext = pathinfo($path, PATHINFO_EXTENSION);
        return strtolower($ext);
    }
}